<?php $this->load->view('layout/lib_chart');?>

<?php 
	$min	=	9999999999;
	$value	=	0;
	if($paramter){
		foreach($row as $k => $v){
			if($v['years_to_university'] < $min){
				$min	=	$v['years_to_university'];
			}
			$CE	=	$paramter->cost_of_university;
			$ei	=	$paramter->education_inflation/100;
			$y	=	$v['years_to_university'];
			$EF	=	$CE*(pow((1+$ei),$y)); 
			$value+=$EF;
		}
		
		//echo $min;
		$current_year	=	date('Y');
		$year	=	intval($min)+intval($current_year);
		$ch		=	$this->current_holding_model->return_value_by_year($year);
		$value	=	round($value);
	}
?>

<script type="text/javascript">
	var chart;
	$(document).ready(function() {
		chart = new Highcharts.Chart({
			chart: {
				renderTo: 'container',
				defaultSeriesType: 'column'
			},
			title: {
				text: 'Education Graph'
			},
			xAxis: {
				categories: ['<?php echo $year;?>']
			},
			yAxis: {
				title: {
					text: ''
				},
				labels: {
					formatter: function() {
						return this.value + '';
					}
				},
				lineWidth: 2,
				min : 0
				
			},
			tooltip: {
				formatter: function() {
					return ''+
						 this.series.name +': '+ this.y +'';
				}
			},
			credits: {
				enabled: false
			},
			series: [{
				name: 'TEF',
				data: [<?php echo $value;?>]
			}, {
				name: 'CH',
				data: [<?php echo $ch;?>]
			}]
		});
		
		
	});
		
</script>

<div id="container" style="width: 800px; height: 400px; margin: 0 auto"></div>